package View.MaintainPage.gMain;


import View.MainPage.Main1;
import View.MaintainPage.gChange.Mainchange;
import View.MaintainPage.gDelete.Maindelete;
import View.MaintainPage.gInsert.Maininsert;
import View.MaintainPage.gSelect.Mainselectgoods;
import View.MaintainPage.gShow.Mainshow;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

public class Mainweihu extends Application {
	@FXML
    private Button addgoods;

    @FXML
    private Button endButton;

    @FXML
    private Button deletegoods;

    @FXML
    private Button selectgoods;

    @FXML
    private Button showall;

    @FXML
    private Button freshgoods;

    @FXML
    void act1(ActionEvent event) {
    	try {
			 new Main1().start(new Stage());
			 
		} catch (Exception e) {
			// TODO: handle exception
		}
    	exitButtonOnMouseClicked(endButton);
}

    @FXML
    void act2(ActionEvent event) {
    	try {
			 new Maininsert().start(new Stage());//�����Ʒ����
			 
		} catch (Exception e) {
			// TODO: handle exception
		}
    	exitButtonOnMouseClicked(addgoods);
    	
    }

    @FXML
    void act3(ActionEvent event) {
    	try {
			 new Mainchange().start(new Stage());//������Ʒ����
			 
		} catch (Exception e) {
			// TODO: handle exception
		}
    	exitButtonOnMouseClicked(freshgoods);
    }

    @FXML
    void act4(ActionEvent event) {
    	try {
			 new Maindelete().start(new Stage());//ɾ����Ʒ����
			 
		} catch (Exception e) {
			// TODO: handle exception
		}
    	exitButtonOnMouseClicked(deletegoods);
    }

    @FXML
    void act5(ActionEvent event) {
    	try {
			 new Mainselectgoods().start(new Stage());//��ѯ��Ʒ����
			 
		} catch (Exception e) {
			// TODO: handle exception
		}
    	exitButtonOnMouseClicked(selectgoods);
    }

    @FXML
    void act6(ActionEvent event) {
    	try {
			 new Mainshow().start(new Stage());//չʾ��Ʒ����
			 
		} catch (Exception e) {
			// TODO: handle exception
		}
    	exitButtonOnMouseClicked(showall);
    }

    public void exitButtonOnMouseClicked(Button exitButton) {
        Stage stage = (Stage)exitButton.getScene().getWindow();
        stage.close();
    }

	@Override
	public void start(Stage primaryStage) {

		try {
			Class clazz = getClass();
			Parent root = FXMLLoader.load(clazz.getResource("Mainweihu.fxml"));
			Scene scene = new Scene(root, 600, 600);
			scene.getStylesheets().add(getClass().getResource("/sources/Css/application1.css").toExternalForm());
			primaryStage.setScene(scene);
			primaryStage.show();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public static void main(String[] args) {
		launch(args);
	}

}
